package com.cxhc.app.api.hcdoc;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cxhc.system.domain.hcdoc.HdSmallBid;
import com.cxhc.system.service.hcdoc.IHdSmallBidService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cxhc.common.core.controller.BaseController;
import com.cxhc.common.core.domain.AjaxResult;
import com.cxhc.common.utils.poi.ExcelUtil;
import com.cxhc.common.core.page.TableDataInfo;

/**
 * 小额招标信息Controller
 * 
 * @author Dhq
 * @date 2024-09-26
 */
@RestController
@RequestMapping("/api/hcDoc/smallBid")
public class HdSmallBidController extends BaseController
{
    @Autowired
    private IHdSmallBidService hdSmallBidService;

    /**
     * 查询小额招标信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HdSmallBid hdSmallBid)
    {
        startPage();
        List<HdSmallBid> list = hdSmallBidService.selectHdSmallBidList(hdSmallBid);
        return getDataTable(list);
    }

    /**
     * 导出小额招标信息列表
     */
    @GetMapping("/export")
    public void export(HttpServletResponse response, HdSmallBid hdSmallBid)
    {
        List<HdSmallBid> list = hdSmallBidService.selectHdSmallBidList(hdSmallBid);
        ExcelUtil<HdSmallBid> util = new ExcelUtil<HdSmallBid>(HdSmallBid.class);
        util.exportExcel(response, list, "小额招标信息数据");
    }

    /**
     * 获取小额招标信息详细信息
     */
    @GetMapping(value = "/detail/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hdSmallBidService.selectHdSmallBidById(id));
    }

    /**
     * 新增小额招标信息
     */
    @PostMapping("/insert")
    public AjaxResult add(@RequestBody HdSmallBid hdSmallBid)
    {
        return toAjax(hdSmallBidService.insertHdSmallBid(hdSmallBid));
    }

    /**
     * 修改小额招标信息
     */
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody HdSmallBid hdSmallBid)
    {
        return toAjax(hdSmallBidService.updateHdSmallBid(hdSmallBid));
    }

    /**
     * 删除小额招标信息
     */
    @GetMapping(value = "/delete/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(hdSmallBidService.deleteHdSmallBidById(id));
    }
}
